package com.itheima.web;

import com.itheima.servcie.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {
    @Autowired
    private TanhuaService tanhuaService;

    /**
     * 今日佳人
     * @return
     */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
        return ResponseEntity.ok().body(tanhuaService.todayBest());
    }

    /**
     * 佳人信息
     * @param id
     * @return
     */
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable Long id){
        return ResponseEntity.ok(tanhuaService.personalInfo(id));
//        return ResponseEntity.ok(null);
    }

    /**
     * @RequestParam(defaultValue = "1") Integer page,
     * @RequestParam(defaultValue = "10") Integer pagesize
     * @param page
     * @param pagesize
     * @return
     */
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(@RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "10") Integer pagesize){
        return ResponseEntity.ok(tanhuaService.recommendation(page, pagesize));
    }

    /**
     * 查询陌生人问题
     * @param userId
     * @return
     */
    @GetMapping("/strangerQuestions")
    private ResponseEntity strangerQuestions(String userId){
        return ResponseEntity.ok(tanhuaService.strangerQuestions(userId));
    }

    /**
     * 回复陌生人消息
     * @param map
     * @return
     */
    @PostMapping("/strangerQuestions")
    private ResponseEntity replyQuestions(@RequestBody Map map){
        tanhuaService.replyQuestions(map);
        return ResponseEntity.ok(null);
    }

    /**
     * 左滑右滑
     * @return
     */
    @GetMapping("/cards")
    public ResponseEntity cards(){
        return ResponseEntity.ok(tanhuaService.cards());
    }

    /**
     * 喜欢
     * @param id
     * @return
     */
    @GetMapping("/{id}/love")
    public ResponseEntity love(@PathVariable Long id){
        tanhuaService.love(id);
        return ResponseEntity.ok(null);
    }

    /**
     * 不喜欢
     * @param id
     * @return
     */
    @GetMapping("/{id}/unlove")
    public ResponseEntity unlove(@PathVariable Long id){
        tanhuaService.unlove(id);
        return ResponseEntity.ok(null);
    }

    /**
     * 搜附近
     * @param gender
     * @param distance
     * @return
     */
    @GetMapping("/search")
    public ResponseEntity search(String gender, Integer distance){
        return ResponseEntity.ok(tanhuaService.search(gender, distance));
    }
}
